#pragma once

#include <semaphore.h>
#include <libusb-1.0/libusb.h>

//passive auth flags
#define PA_STOP    0x00
#define PA_START   0x01
#define PA_SUCCESS 0x02
#define PA_FAILED  0x03


#define BUFLEN_PACKETDATA 2052
#define BUFLEN_RAMDATA 96
#define BUFLEN_DATA 38912

#define MODE_IDLE            0x00
#define MODE_TOUCHPAD        0x10
#define MODE_TOUCHPAD_MOUSE  0x11
#define MODE_TOUCHPAD_WHEELS 0x12
#define MODE_TOUCHPAD_ARROWS 0x13
#define MODE_SCANNING        0x20

#define STATE_RUNNING  0x00
#define STATE_WAIT_IPC 0x01
//#define STATE_ERROR    0x02

struct driverInstance {
	
	libusb_device_handle* deviceHandle;
	int launcherdSocket;
	
	sem_t semaphoreIpc;
	sem_t semaphoreIdle;
	sem_t semaphoreScan;
	sem_t semaphoreInterrupt;
	
	unsigned char modeIndicator;
	unsigned char modeSwitcher;
	unsigned char touchpadMode;
	unsigned char driverState;
	
	unsigned char requestCounter;
	
	//send
	unsigned char sendPacketType;
	int           sendPacketMessageLength;
	
	//rcv means received
	unsigned char rcvPacketType;
	int           rcvPacketMessageLength;
	
	//packet buffer
	unsigned char  _packetData[BUFLEN_PACKETDATA];
	unsigned char* packetMessage;// &_packetData[7]
	
	//data buffer
	unsigned char data[BUFLEN_DATA];
	int           dataLength;
	
	//ram buffer
	unsigned char ramData[BUFLEN_RAMDATA];
	
	//interrupt and control
	int           interruptStatus;
	unsigned char controlStatus[8];
	
	//used for communicate between driver and ipcd in scan mode
	int           scanResult;
	unsigned char scanQuality;
	
	//used to communicate between driver and ipcd in passive auth
	char*         passiveAuthUsername;
	unsigned char passiveAuthModeSwitcher;
	unsigned char passiveAuthModeIndicator;
	
};

